home *** CD-ROM | disk | FTP | other *** search
/ Delphi Developer's Kit 1996 / Delphi Developer's Kit 1996.iso / power / fbuf / bufftest.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-12-22  |  4.2 KB  |  122 lines

  1. unit BuffTest;
  2. {
  3.    Project "Test File Buffering"
  4.    Opnek Research
  5.    Copyright ⌐ 1995. All Rights Reserved.
  6.  
  7.    SUBSYSTEM:      FileBuff test stub
  8.    FILE:           BuffTest.Pas
  9.    AUTHOR:         Jay Cole
  10.    WRITTEN:        05/10/95
  11.    LAST ASSERT:    0
  12.                                                                                
  13.    OVERVIEW                                                                    
  14.    ========                                                                    
  15.    Provides an interactive way to test the buffering schemes against unbuffered.
  16.    Also it allows us to improve FileBuff and test the results of the new scheme
  17.    against the old.  _TESTHARNESS is defined in the Option|Project section of 
  18.    this project.  We also leave out the Assert Code by defining _NDEBUG in the 
  19.    project so we don't have the overhead call for checking assertions.
  20.  
  21.    CAUTIONS
  22.    ========
  23.    - Make sure the Far calls are turned on for the project, that way we can gauge
  24.    the impact of far calls (inter module) on the system.  They shouldn't be much.
  25.    - Add integrity checks to make sure the buffered version matches the unbuffered
  26.    version.
  27.  
  28.    UPDATE HISTORY
  29.    ==============
  30.    05/10/95 - Created
  31.    05/13/95 - Added user defined buffersize/recordsize/iterations
  32. }
  33.  
  34. interface
  35. {$define _TESTHARNESS } {<- This must be defined in your project in order to run }
  36.  
  37. uses
  38.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  39.   Forms, Dialogs, StdCtrls;
  40.  
  41. type
  42.   TForm1 = class(TForm)
  43.     Button1: TButton;
  44.     Label1: TLabel;
  45.     Label2: TLabel;
  46.     Label3: TLabel;
  47.     Label4: TLabel;
  48.     FileCreateResult: TEdit;
  49.     UniformCopyResult: TEdit;
  50.     FileReadResults: TEdit;
  51.     ModifyInPlaceResults: TEdit;
  52.     FileCreate2: TEdit;
  53.     FileCopy2: TEdit;
  54.     FileReadResults2: TEdit;
  55.     FileModify2: TEdit;
  56.     Label5: TLabel;
  57.     Label6: TLabel;
  58.     Label7: TLabel;
  59.     Write64k: TEdit;
  60.     Read64k: TEdit;
  61.     Label8: TLabel;
  62.     Label9: TLabel;
  63.     BuffSize: TEdit;
  64.     Label10: TLabel;
  65.     RecSize: TEdit;
  66.     Label11: TLabel;
  67.     NumIter: TEdit;
  68.     procedure Button1Click(Sender: TObject);
  69.   private
  70.     { Private declarations }
  71.   public
  72.     { Public declarations }
  73.   end;
  74.  
  75. var
  76.   Form1: TForm1;
  77.  
  78. implementation
  79. uses FileBuff;
  80.  
  81. {$R *.DFM}
  82.  
  83. { Kick off the test and fill in the results }
  84. procedure TForm1.Button1Click(Sender: TObject);
  85. var oldCreateTime, oldCopyTime, oldReadTime, oldModifyTime : double;
  86.     newCreateTime, newCopyTime, newReadTime, newModifyTime : double;
  87.     numBufSize, numRecSize : word;
  88.     numNumIter : longint;
  89.     writeBench, readBench : double;
  90. begin
  91.    { First, get our information }
  92.    numBufSize := StrToInt(BuffSize.Text);
  93.    numRecSize := StrToInt(RecSize.Text);
  94.    numNumIter := StrToInt(NumIter.Text);
  95.    oldCreateTime := 0.0; oldCopyTime := 0.0; oldReadTime := 0.0; oldModifyTime := 0.0;
  96.    newCreateTime := 0.0; newCopyTime := 0.0; newReadTime := 0.0; newModifyTime := 0.0;
  97.  
  98.    { Call the tester }
  99.    FileBuff.TestFileBuff(
  100.       numBufSize, numRecSize, numNumIter,
  101.       oldCreateTime, oldCopyTime, oldReadTime, oldModifyTime,
  102.       newCreateTime, newCopyTime, newReadTime, newModifyTime,
  103.       writeBench, readBench
  104.    );
  105.  
  106.    { Buffered/UnBuffered timings }
  107.    FileCreateResult.Text        := FloatToStrF(oldCreateTime, ffNumber, 4, 2) + ' secs';
  108.    UniformCopyResult.Text       := FloatToStrF(oldCopyTime, ffNumber, 4, 2) + ' secs';
  109.    FileReadResults.Text         := FloatToStrF(oldReadTime, ffNumber, 4, 2) + ' secs';
  110.    ModifyInPlaceResults.Text    := FloatToStrF(oldModifyTime, ffNumber, 4, 2) + ' secs';
  111.    FileCreate2.Text             := FloatToStrF(newCreateTime, ffNumber, 4, 2) + ' secs';
  112.    FileCopy2.Text               := FloatToStrF(newCopyTime, ffNumber, 4, 2) + ' secs';
  113.    FileReadResults2.Text        := FloatToStrF(newReadTime, ffNumber, 4, 2) + ' secs';
  114.    FileModify2.Text             := FloatToStrF(newModifyTime, ffNumber, 4, 2) + ' secs';
  115.  
  116.    { Raw bench marks for best speed }
  117.    Write64k.Text                := FloatToStrF(writeBench, ffNumber, 4, 2) + ' secs';
  118.    Read64k.Text                 := FloatToStrF(readBench, ffNumber, 4, 2) + ' secs';
  119. end;
  120.  
  121. end.
  122.